package org.xuk.spring.ws.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.xuk.spring.ws.model.BoardCastMessage;
import org.xuk.spring.ws.model.SingleMessage;

@Slf4j
@Component
public class ReceivedMessageHandler {
    private final WsMessageClient wsMessageClient;

    public ReceivedMessageHandler(WsMessageClient wsMessageClient) {
        this.wsMessageClient = wsMessageClient;
    }

    public void handleSingleMessage(SingleMessage singleMessage) {
        wsMessageClient.sendToUsers(singleMessage.getUserIds(), singleMessage);
    }


    public void handleBoardCastMessage(BoardCastMessage boardCastMessage) {
        wsMessageClient.boardCast(boardCastMessage);
    }
}
